﻿using CCWin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TelephoneYiShou;

namespace employee
{
    public partial class empAdd : Skin_Mac
    {
        public empAdd()
        {
            InitializeComponent();
        }

        private void btn_add_Click(object sender, EventArgs e)
        {
            //添加            
            string empname = txt_name.Text;
            string dept = cmb_dept.Text;
            string salary = txt_salary.Text;
            string phone = txt_tel.Text;
            string sex = cmb_sex.Text;
            string code = txt_code.Text;
            string address = txt_address.Text;
            string birth =dateTimePicker1.Text;
            if (string.IsNullOrEmpty(empname) || string.IsNullOrEmpty(dept) ||
                string.IsNullOrEmpty(salary) || string.IsNullOrEmpty(phone) ||
                string.IsNullOrEmpty(sex) || string.IsNullOrEmpty(code) ||
                string.IsNullOrEmpty(address) || string.IsNullOrEmpty(birth))
            {
                MessageBoxEx.Show("信息输入不完整！");
                return;//直接返回
            }
            string sql = string.Format("insert into Employee Values" +
                "('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",empname, salary,sex, phone,address, dept, code,Convert.ToDateTime(birth));
            if (DBHelper.ExecuteNonQuery(sql))
            {
                MessageBoxEx.Show("员工信息添加成功！");
            }
            else
            {
                MessageBoxEx.Show("添加失败,请联系管理员!");
            }
        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            //退出
            this.Close();
        }
    }
}
